local ls = require("luasnip")
local s = ls.snippet
local t = ls.text_node
local i = ls.insert_node
local fmt = require("luasnip.extras.fmt").fmt

ls.add_snippets("html", {
  -- Dialog
  s("dialog", fmt("<dialog>{}</dialog>", {i(0)})),

  -- Line break
  s("br", t("<br />")),

  -- Horizontal rule
  s("hr", t("<hr />")),

  -- Render
  s("rd", fmt("<%={} %>", {i(0)})),

  -- HTML Comments
  s("ch", fmt([[
<!--
  {}
-->]], {i(0)})),

  s("c", fmt("<!-- {} -->", {i(0)})),

  -- CSS/JS Comments
  s("cs", fmt([[
/*
  {}
 */]], {i(0)})),

  s("cc", fmt("// {}", {i(0)})),

  s("csl", fmt("/* {} */", {i(0)})),

  -- Console log
  s("st", fmt("console.log({});", {i(0)})),
})

-- HTML 片段也可以在其他 web 相关文件中使用
ls.filetype_extend("javascript", { "html" })
ls.filetype_extend("typescript", { "html" })
